import Vue from 'vue'
import Router from 'vue-router'

/* Layout */
import Layout from '../views/layout/Layout'

Vue.use(Router)


/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/


export const constantRouterMap = [
  {path: '/login', component: () => import('../views/login/index'), hidden: true},
  {path: '/404', component: () => import('@/views/404'), hidden: true},

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },
  {
    path: '/configmanager',
    component: Layout,
    redirect: '/dashboard',
    name: 'configmanager',
    meta: {title: '配置管理', icon: 'setting', prem: 'config_group'},
    children: [
      {
        path: 'problemstype',
        name: 'problemstType',
        component: () => import('@/views/problemsType/index'),
        meta: {title: '问题类型配置', icon: 'setting', prem: 'problem_type'}
      }, {
        path: 'commonprolems',
        name: 'commonprolems',
        component: () => import('@/views/commonProlems/index'),
        meta: {title: '常见问题配置', icon: 'setting', prem: 'common_problem'}
      }, {
        path: 'commonstatement',
        name: 'commonstatement',
        component: () => import('@/views/commonStatement/index'),
        meta: {title: '客服常用语配置', icon: 'setting', prem: 'phrase'}
      }, {
        path: 'bulletin',
        name: 'bulletin',
        component: () => import('@/views/bulletin/index'),
        meta: {title: '客服公告配置', icon: 'setting', prem: 'announcement'}
      }
    ]
  },
  {
    path: '/recharge',
    component: Layout,
    redirect: '/dashboard',
    name: 'recharge',
    meta: {title: '工单管理', icon: 'setting', prem: 'order_group'},
    children: [
      {
        path: 'rechargeappeal',
        name: 'rechargeappeal',
        component: () => import('@/views/rechargeAppeal/index'),
        meta: {title: '充值申诉', icon: 'setting', prem: 'appeal'}
      },
      {
        path: 'receipt',
        name: 'receipt',
        component: () => import('@/views/receipt/index'),
        meta: {title: '客服回单', icon: 'setting', prem: 'customer_order'}
      },

      {
        path: 'workOrderQuery',
        name: 'workOrderQuery',
        component: () => import('@/views/workOrderQuery/index'),
        meta: {title: '工单查询', icon: 'setting', prem: 'order_query'}
      },
      {
        path: 'workorder',
        name: 'workorder',
        component: () => import('@/views/workOrder/index'),
        meta: {title: '工单管理', icon: 'setting', prem: 'work_order'}
      },
      {
        path: 'loginhelp',
        name: 'loginhelp',
        component: () => import('@/views/loginHelp/index'),
        meta: {title: '登录申诉', icon: 'setting', prem: 'login_order'}
      },
      {
        path: 'transferrecord',
        name: 'transferrecord',
        component: () => import('@/views/transferRecord/index'),
        meta: {title: '转接记录', icon: 'setting', prem: 'reassign'}
      }
    ]
  },
  {
    path: '/reportManager',
    component: Layout,
    redirect: '/dashboard',
    name: 'reportManager',
    meta: {title: '数据报表', icon: 'setting', prem: 'data_group'},
    children: [
      {
        path: 'report',
        name: 'report',
        component: () => import('@/views/report/index'),
        meta: {title: '报表管理', icon: 'setting', prem: 'report'}
      },
      {
        path: 'performance',
        name: 'performance',
        component: () => import('@/views/performance/index'),
        meta: {title: '绩效管理', icon: 'setting', prem: 'performance'}
      },
      {
        path: 'segment',
        name: 'segment',
        component: () => import('@/views/segment/index'),
        meta: {title: '分时数据', icon: 'setting', prem: 'segment_report'}
      }
    ]
  },
  {
    path: '/auth',
    component: Layout,
    redirect: '/dashboard',
    name: 'auth',
    meta: {title: '权限管理', icon: 'setting', prem: 'admin_group'},
    children: [
      {
        path: 'user',
        name: 'user',
        component: () => import('@/views/userMag/index'),
        meta: {title: '用户管理', icon: 'setting', prem: 'admin_user_group'}
      }, {
        path: 'role',
        name: 'role',
        component: () => import('@/views/roleMag/index'),
        meta: {title: '角色管理', icon: 'setting', prem: 'admin_role_group'}
      }
    ]
  },

  {path: '*', redirect: '/404', hidden: true}
]

export default new Router({
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})

